﻿using System;
using System.Windows.Forms;

namespace ShkSimulation.desktop.component.tools {
    public partial class SingleTextInputForm : Form {
        
        public SingleTextInputForm() {
            InitializeComponent();
        }
        
        private string inputMessage = "";
        
        public string InfoText {
            set { this.InfoLabel.Text = value; }
        }
        
        public string FormTitle {
            set { this.Text = value; }
        }
        
        public string InputMessage => inputMessage;

        private void CertainButton_Click(object sender, EventArgs e) {
            this.inputMessage = this.SingleInputTextBox.Text.Trim();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void CancelButton_Click(object sender, EventArgs e) {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        public static string GetInput(string title = "输入框", string tip = "请在下方输入:") {
            SingleTextInputForm inputForm = new SingleTextInputForm();
            inputForm.InfoLabel.Focus();
            inputForm.FormTitle = title;
            inputForm.InfoText = tip;
            inputForm.ShowDialog();
            string uniqueKey = inputForm.InputMessage;
            return uniqueKey;
        }

    }
}
